<template>
	<view style="width: 100%; height: 100%;">
		<view class="tabs">
			<view v-for="(tab, index) in tabs" :key='index' class="tab-item" :class="current==index?'active_type':'a_type'"
				@click="current = index">
				{{tab.title}}
			</view>
		</view>
		<swiper :current="current" class="swiper-box" style="position: absolute;top: 200rpx;left: 0;padding-bottom: 200rpx;" @change="onChange">
			<swiper-item v-for="(item ,index) in tabs" :key="index">
				<scroll-view scroll-y="true" style="height: 100%;">
					<!-- #ifdef MP -->
					<slot name="{{'content' + index}}"></slot>
					<!-- #endif -->
					<!-- #ifndef MP -->
					<slot :name="'content'+index"></slot>
					<!-- #endif -->
				</scroll-view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		name: 'swiperTab',
		props: {
			currentTab: {
				type: Number,
				default: 0
			},
			tabs: {
				type: Array,
				default: []
			}
		},
		data() {
			return {
				current: this.currentTab
			};
		},
		methods: {
			onChange(e) {
				this.current = e.detail.current;
				this.$emit('change', e.detail.current);
			}
		}
	}
</script>
<style>
	swiper-tab {
		display: block;
		height: 100%;
	}
</style>
<style lang="scss" scoped>
	.active_type {
		color: #FFFFFF;
		font-size: 40rpx;
		font-weight: 600;
	}
	
	.a_type {
		color: #FFFFFF;
		font-size: 26rpx;
		font-weight: 500;
	}
	
	.active_type::after {
		content: ''; // 必须
		position: absolute;
		left: 50%;
		top: 80rpx;
		transform: translateX(-50%);
		width: 60rpx;
		height: 6rpx;
		background-color: #FFFFFF;
	}
	.tabs {
		width: 100%;
		height:200rpx;
		box-sizing: border-box;
		padding: 0 30rpx;
		background: linear-gradient(180deg,#5EC4C2 0%, #F5F5F5 100%);
		// width: 750rpx;
		// height: 75rpx;
		display: flex;
		text-align: center;
		justify-content: space-between;
		.tab-item {
			// flex: 1;
			text-align: center;
			line-height: 80rpx;
			height: 100%;
			box-sizing: border-box;
			position: relative;

			// &.active {
			// 	color: $uni-color-primary;
			// 	border-bottom: 2rpx solid $uni-color-primary;
			// }
		}
	}

	.swiper-box {
		width: 100%;
		height: calc(100% - 75rpx);
		overflow: auto;
	}
</style>
